package com.koron.standard.gradeStock.bean.excel;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.koron.common.core.util.CodeTools;
import com.koron.standard.gradeStock.bean.po.Grade;
import com.koron.standard.gradeStock.bean.po.GradeItem;
import com.koron.standard.gradeStock.excel.GradeStringStringConvertor;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author jzp
 * @since 2022/5/30
 */
@ExcelIgnoreUnannotated
@Data
@ApiModel(value = "大修分级分项验收标准导出数据", description = "GradeExcel")
public class GradeExcel {

    @ExcelProperty(index = 0)
    @ApiModelProperty("分类ID")
    private String typeId;

    @ExcelProperty(index = 1)
    @ApiModelProperty("分类名称")
    private String typeName;

    @ExcelProperty(index = 2)
    @ApiModelProperty("标题")
    private String name;

    @ExcelProperty(index = 3)
    @ApiModelProperty("分级分项名称")
    private String gradeName;

    @ExcelProperty(index = 4, converter = GradeStringStringConvertor.class)
    @ApiModelProperty("验收级别")
    private Integer level;

    @ExcelProperty(index = 5, converter = GradeStringStringConvertor.class)
    @ApiModelProperty("专业")
    private String major;

    @ExcelProperty(index = 6)
    @ApiModelProperty("项目描述")
    private String context;

    @ExcelProperty(index = 7)
    @ApiModelProperty("验收标准")
    private String contextStandard;

    public Grade buildGrade() {
        Grade grade = new Grade();
        grade.setId(CodeTools.getCode32());
        grade.setName(name);
        grade.setTypeId(typeId);
        grade.setPublicStatus(0);
        grade.setStatus(1);
        // code, appid, sort
        return grade;
    }

    public GradeItem buildGradeItem(String preGradeId, int i) {
        GradeItem item = new GradeItem();
        item.setGradeId(preGradeId);
        item.setName(gradeName);
        item.setLevel(level);
        item.setMajor(major);
        item.setContext(context);
        item.setContextStandard(contextStandard);
        item.setSort(i);
        return item;
    }
}
